
package com.rt.schedulenew.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rt.schedulebase.dto.DictExamSubclassDto;
import com.rt.schedulebase.entity.DictExamSubclass;
import com.rt.schedulebase.mapper.DictExamSubclassMapper;
import com.rt.schedulenew.api.IDictExamSubclassService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DictExamSubclassServiceImpl extends ServiceImpl<DictExamSubclassMapper, DictExamSubclass> implements IDictExamSubclassService
{
    @Override
    public List<DictExamSubclass> getList(DictExamSubclassDto dto) {
        QueryWrapper<DictExamSubclass> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<>();
        map.put("EXAM_CLASS_NAME", dto.getExamClassName());
        qw.allEq(map, false);
        List<DictExamSubclass> list = baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<DictExamSubclass> getListAll() {
        return baseMapper.selectList(null);
    }

    @Override
    public boolean delete(DictExamSubclass dictExamSubclass) {
        UpdateWrapper<DictExamSubclass> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("EXAM_CLASS_NAME", dictExamSubclass.getExamClassName());
        uw.allEq(map, false);
        return retBool(baseMapper.delete(uw));
    }

    @Override
    public boolean update(DictExamSubclass dictExamSubclass) {
        UpdateWrapper<DictExamSubclass> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<>();
        map.put("EXAM_CLASS_NAME", dictExamSubclass.getExamClassName());
        uw.allEq(map, false);
        return retBool(baseMapper.update(dictExamSubclass, uw));
    }

    @Override
    public DictExamSubclass getInfo(DictExamSubclassDto dto) {
        QueryWrapper<DictExamSubclass> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("EXAM_CLASS_NAME", dto.getExamClassName());
        qw.allEq(map, false);
        return baseMapper.selectOne(qw);
    }
}
